package password

import (
	"crypto/md5"
	"fmt"
)

const SALT string = "JOJO123123"

func Marshal(password string) string {
	prev := password[0:4]
	next := password[4 : len(password)-1]
	newPassword := fmt.Sprintf("%s:%s:%s", prev, SALT, next)
	m := md5.New()
	res := m.Sum([]byte(newPassword))
	return fmt.Sprintf("%x", res)
}

func Verify(password string, saltPassword string) bool {
	password = Marshal(password)
	return saltPassword == password
}
